﻿@{
    Layout = null;
    DeliveryManage.Models.ReturnMsgModel returnMsg = ViewBag.ReturnMsgModel;
}
@model DeliveryManage.Model.Pro_ShopGoods
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>选择套餐</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <link rel="stylesheet" href="~/Content/font.css">
    <link rel="stylesheet" href="~/Content/framemain.css">
    <link rel="stylesheet" href="~/Content/pagination.css" />
    <script type="text/javascript" src="~/Content/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="~/Scripts/common.js"></script>
    <script type="text/javascript" src="~/Scripts/framemain.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <style>
        .layui-table img {
            max-width: inherit;
        }

        .pro-img {
            border-radius: 5px;
            border: 1px solid #f2f2f2;
        }
    </style>
</head>
<body>
    @using (Html.BeginForm("SelectGoods", "Order", FormMethod.Get, new { name = "myform" }))
    {
        if (returnMsg.code == 200)
        {
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card layui-form">
                            <div class="layui-card-header">
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" class="layui-input" name="keywords" id="keywords" value="@ViewBag.Keyword" placeholder="请输入产品编码或名称" />
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="hidden" name="pageSize" id="pageSize" value="@ViewData["pageSize"]" />
                                    <input type="hidden" name="page" id="page" value="@ViewData["page"]" />
                                    <input type="hidden" name="selectGoodsId" id="selectGoodsId" value="0" />
                                </div>
                                <input type="submit" value="&#xe615; 查询" class="layui-btn layui-btn-select layui-icon" />
                                @*<a class="layui-btn" onclick="GetSelectRadio();"><i class="layui-icon">&#xe61f;</i>提交</a>*@
                            </div>
                            <div class="layui-card-body ">
                                <table class="layui-table layui-form">
                                    <thead>
                                        <tr>
                                            <th>商品编码</th>
                                            <th>套餐名称</th>
                                            <th>套餐类型</th>
                                            <th>价格</th>
                                            <th>规格(箱)</th>
                                            <th>数量(瓶)</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @{
                                            if (ViewBag.ProductList.Count > 0)
                                            {
                                                foreach (DeliveryManage.Model.Pro_ShopGoods item in ViewBag.ProductList)
                                                {
                                                    <tr>
                                                        <td>
                                                        <input type="checkbox" name="checkCode" lay-skin="primary" lay-filter="checkCode" title="@item.Code" value="@item.Id">

                                                            @*<input type="radio" name="selectradio" lay-skin="primary" class="selectradio" value="@item.Id" />*@
                                                            <input type="hidden" name="hidid" value="@item.Id" />
                                                        </td>
                                                        <td>@item.Name</td>
                                                        <td>@(item.Lable?"标准套餐":"活动促销")</td>
                                                        <td>@item.CounterPrices</td>
                                                        <td>@item.CalcSpec 【@(item.SpecUnit == "0" ? "箱":"件")】</td>
                                                        <td>@item.SpecNum</td>
                                                    </tr>
                                                }
                                            }
                                            else
                                            {
                                                <tr>
                                                    <td colspan="8" align="center" height="200"><img src="~/images/nodata.png" style=" width: 10%; " /><br /> 暂无相关数据</td>
                                                </tr>
                                            }
                                        }

                                    </tbody>
                                </table>
                            </div>

                            <div class="pagelist">
                                <div id="PageContent" class="default">@Html.Raw(ViewBag.PageInnerHtml)</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        }
    }

    <script type="text/javascript">
    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        var form = layui.form;
        // 更新复选框组的选中状态
        form.render('checkbox');

        // 单选处理
        form.on('checkbox(checkCode)', function (data) {
            //全部取消选中            
            $("input[name='checkCode']").prop("checked", false);
            //全部取消选中
            $(this).prop("checked", true);
            //重新渲染checkbox。                   
            form.render('checkbox');
        });

        //切换分页大小
        form.on('select(selectpage)', function (data) {
            var data = thisdata();//搜索条件
            locations(data);
        })
    });

    // 监听单选
    function GetSelectRadio() {
        var radios = document.getElementsByName('checkCode');
        for (var i = 0; i < radios.length; i++) {
            if (radios[i].checked) {
                alert(radios[i].value);
                $("#selectGoodsId").val(radios[i].value);
                break; // 找到后退出循环
            }
        }
    }
    //搜索参数函数
    function thisdata()
    {
        var data = {
            pageCount: $('.txtPageCount').val(),
            pageSize: $("select[name=select_page").val(), //获取到所选的id
            keywords: $('#keywords').val(),
        };

        if (data.pageCount=="") {
            data.pageCount= @ViewData["page"];
        }
        return data;
    }

    //调用页面方法
    function locations(data) {
        window.location.href = '/Order/SelectGoods?page=' + data.pageCount + "&pageSize=" + data.pageSize + '&keywords=' + data.keywords;
        }

      $(function () {
            //操作提示
            if (@returnMsg.code == 400) {
                layer.msg('@returnMsg.msg', { icon: 5, title: '提示' }, function (index) {
                  layer.close();
                })
            }

            //跳转页
            $("#locationPageBtn").click(function () {
                var data = thisdata();//搜索条件
                locations(data);
            });
        })
    </script>
</body>
</html>
